package com.apestech.framework.xml.condition.modul;

import com.apestech.framework.json.JSONObject;

/**
 * @author hup
 * @create 2019-01-23-10:17
 */
public class Field {
    private String id;
    private String name;
    private String field;
    private Integer count;
    private String result;
    private String ladder;
    private String update;
    private String type;
    private String defaultValue;
    private String totalControl;

    public void setField(JSONObject map) throws Exception {
        this.id=map.getString("id");
        this.name=map.getString("name");
        this.field=map.getString("field");
        this.count=map.getInteger("count");
        this.result=map.getString("result");
        this.ladder=map.getString("ladder");
        this.update=map.getString("update");
        this.type=map.getString("type");
        this.defaultValue=map.getString("defaultValue");
        this.totalControl=map.getString("totalControl");
        if(this.field==null) this.field=this.id;
    }

    public String getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public String getField() {
        return field;
    }

    public void setType(String type) {
        this.type = type;
    }

    public boolean isResult() {
        if(result==null) return false;
        return "1".equals(result);
    }

    public boolean isLadder() {
        if(ladder==null) return false;
        return "1".equals(ladder);
    }

    public boolean isUpdate() {
        if(update==null) return false;
        return "1".equals(update);
    }

    public boolean isTotalControl() {
        if(totalControl==null) return false;
        return "1".equals(totalControl);
    }

    public Integer getCount() {
        return count;
    }

    public String getType() {
        return type;
    }

    public String getDefaultValue() {
        return defaultValue;
    }

}
